#include "operationlog.h"

//constructor for add/delete operation
void OperationLog::set(Operation op,Record record,int option)
{
    this->option = option;
    oldRecord = record;
    if(op==add_Record)
        undo=delete_Record;
    if(op==delete_Record)
        undo=add_Record;
}
//constructor for modify operation
void OperationLog::set(Operation op,Record oldRecord,Record newRecord,int option)
{
    this->option = option;
    undo=op;
    this->oldRecord = oldRecord;
    this->newRecord= newRecord;
}

Operation OperationLog::operationUndo()
{
    return undo;
}
int OperationLog::getOption(){
    return option;
}

Record OperationLog::getOldRecord()
{
    return oldRecord;
}
Record OperationLog::getNewRecord(){
    return newRecord;
}

void OperationLog::print()
{

    qDebug()<<"OperationLog:"<<endl;
    qDebug()<<"Undo Operator: ";
    if(undo==add_Record)
        qDebug()<<"addRecord"<<endl;
    if(undo==delete_Record)
        qDebug()<<"deleteRecord"<<endl;
    if(undo==modify_Record)
        qDebug()<<"modifyRecord"<<endl;
    qDebug()<<"Undo Record:"<<endl;
    newRecord.print();
}
